import { _decorator,director, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
import { ResCache } from '../../core/res/res-cache';
import { Game } from '../data/game'

@ccclass('init')
export class init extends Component {
    start() {
        // 设置常驻节点不被销毁
        director.addPersistRootNode(this.node);

        //加载资源到缓存
        ResCache.Instance.load(async () => {
            //执行游戏主逻辑初始化函数
            Game.Instance.init();
        });

        // setTimeout(() => {
        //     console.log(ResCache.Instance,"init.start--异步")
        //     ResCache.Instance.load(async () => {
        //         //执行游戏主逻辑初始化函数
        //         Game.Instance.init();
        //     });
        // }
        // ,100000)
    }

    update(deltaTime: number) {
        //推动游戏主逻辑更新
        Game.Instance.update(deltaTime);
    }
}


